/* This Genie will fit text into a box or chain of boxes, keeping the proportions of differing sizes of text in a box. All the text in a box or linked chain will be changed. No new boxes are created, unlike AutoImport. The text must be already in the box before running the genie.
Note that any style tags applying to the text will be cancelled.
The limiting factor for accurate fitting is the 1/8 point step in the available font sizes. I have set the genie to underflow rather than overflow.
Written by Don Cox July 92 Revised July 93 Not Public Domain. All rights reserved. */
trace n
signal on error
signal on syntax
address command
call SafeEndEdit.rexx()
call ppm_AutoUpdate(0)
cr="0a"x
cpage = ppm_CurrentPage()
counter=0
do forever
box=ppm_ClickOnBox("Click on boxes to be fitted")
if box=0 then break
counter=counter+1
boxes.counter=box
call ppm_SelectBox(box)
end
if counter=0 then exit_msg("No boxes selected")
currentunits=ppm_GetUnits()
call ppm_SetUnits(2)
call ppm_ShowStatus(" Fitting text...")
do i=1 to counter
box=boxes.i
boxtype = upper(word(ppm_GetBoxInfo(box), 1))
if boxtype~="TEXT" then iterate
box = ppm_ArtFirstBox(box)
text = ppm_GetArticleText(box,1)
iter = 1
factor = 0.5 /* first find max size quickly */
do 9 /* 9 is enough doublings */
factor2 = factor /* format number for display */
if pos(".",factor2) = 0 then factor2 = factor||"."